package com.wnnight.wys.excelHandler;

import com.alibaba.excel.metadata.Head;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.write.handler.CellWriteHandler;
import com.alibaba.excel.write.metadata.holder.WriteSheetHolder;
import com.alibaba.excel.write.metadata.holder.WriteTableHolder;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * @author rzh6230
 * 2022/9/1 16:03
 */
public class LandlordHandler implements CellWriteHandler {

    private static final Logger LOGGER = LoggerFactory.getLogger(LandlordHandler.class);

    @Override
    public void beforeCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Row row,
                                 Head head, Integer columnIndex, Integer relativeRowIndex, Boolean isHead) {
    }

    @Override
    public void afterCellCreate(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, Cell cell,
                                Head head, Integer relativeRowIndex, Boolean isHead) {

    }

    @Override
    public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder, List<WriteCellData<?>> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
        if (!isHead && cell.getColumnIndex() == 6) {
            if ("y".equals(cell.getStringCellValue())){
                cell.setCellValue("已认证");
            } else if ("n".equals(cell.getStringCellValue())) {
                cell.setCellValue("未认证");
            }else if ("x".equals(cell.getStringCellValue())) {
                cell.setCellValue("已迁出");
            }else if ("s".equals(cell.getStringCellValue())) {
                cell.setCellValue("待审核");
            }
        }
    }
}
